#ifndef UIINTERFACE_H
#define UIINTERFACE_H

#include <QObject>
#define UIINTERFACE (UIInterface::instance())

class UIInterface : public QObject
{
    Q_OBJECT
public:
    typedef enum{
        H12,
        H24
    }TimeFormat;
    Q_ENUM(TimeFormat)
    typedef enum{
        DarkTheme,
        LightTheme
    }Theme;
    Q_ENUM(Theme)
public:
    explicit UIInterface(QObject *parent = nullptr);
    static UIInterface* instance();


    bool getHideSecondEn() const;
    void setHideSecondEn(bool newHideSecondEn);

    double getScale() const;
    void setScale(double newScale);

    TimeFormat getTimeFormat() const;
    void setTimeFormat(TimeFormat newTimeFormat);

    bool getShowAPMEn() const;
    void setShowAPMEn(bool newShowAPMEn);

    Theme getTheme() const;
    void setTheme(Theme newTheme);

    QString getTextColor() const;
    void setTextColor(const QString &newTextColor);

private slots:

signals:

    void hideSecondEnChanged();

    void scaleChanged();

    void timeFormatChanged();

    void showAPMEnChanged();

    void themeChanged();

    void textColorChanged();

private:
    void _InitSys();
    void _setValue(const QString &key, const QVariant &value);
    QVariant _getValue(const QString &key, QVariant defalut);
    void _setFullscreenLandscape();
private:
#ifdef Q_OS_UNIX
#ifdef Q_OS_ANDROID
    const    QString configPath = QStringLiteral("config.ini");
    double scale = 0.75;
#else
#ifdef Q_OS_LINUX
    const    QString configPath = QStringLiteral("/data/config.ini");
    double scale = 0.7;
#else
#ifdef Q_OS_MAC
    const    QString configPath = QStringLiteral("config.ini");
    double scale = 0.846;
#endif
#endif
#endif
#else
    const    QString configPath = QStringLiteral("config.ini");
    double scale = 1;
#endif

    TimeFormat timeFormat = H12;
    Theme theme = DarkTheme;
    bool hideSecondEn = false;
    bool showAPMEn = false;
    QString textColor ;
private:
    Q_PROPERTY(bool hideSecondEn READ getHideSecondEn WRITE setHideSecondEn NOTIFY hideSecondEnChanged FINAL)
    Q_PROPERTY(double scale READ getScale WRITE setScale NOTIFY scaleChanged FINAL)
    Q_PROPERTY(TimeFormat timeFormat READ getTimeFormat WRITE setTimeFormat NOTIFY timeFormatChanged FINAL)
    Q_PROPERTY(bool showAPMEn READ getShowAPMEn WRITE setShowAPMEn NOTIFY showAPMEnChanged FINAL)
    Q_PROPERTY(Theme theme READ getTheme WRITE setTheme NOTIFY themeChanged FINAL)
    Q_PROPERTY(QString textColor READ getTextColor WRITE setTextColor NOTIFY textColorChanged FINAL)
};

#endif // UIINTERFACE_H
